// 上传图片
const express = require('express');
const file = express.Router();
const upload = require('../common/util/upload'); 

// 上传图片的路由
file.post('/upload', upload.single('image'), (req, res) => {
    // 当文件上传成功后
    if (req.file) {
        return res.json({
            status: 'success',
            message: '文件上传成功',
            filePath: req.file.path // 返回文件保存路径
        });
    }
    return res.status(400).json({
        status: 'error',
        message: '文件上传失败'
    });
});

module.exports = file